package com.lzb.findphone.fragment;

import android.content.Intent;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.blankj.utilcode.util.AppUtils;
import com.lzb.findphone.BaseNoModelFragment;
import com.lzb.findphone.R;
import com.lzb.findphone.activity.FeedbackActivity;
import com.lzb.findphone.activity.WebActivity;
import com.lzb.findphone.databinding.FragmentMyBinding;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link MyFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class MyFragment extends BaseNoModelFragment<FragmentMyBinding> implements View.OnClickListener {


    @Override
    protected int onCreate() {
        return R.layout.fragment_my;
    }

    @Override
    protected void initView() {
        mDataBinding.llFeedback.setOnClickListener(this);
        mDataBinding.llPrivacy.setOnClickListener(this);
        mDataBinding.llAgreement.setOnClickListener(this);
        mDataBinding.llWithdraw.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.llFeedback) {//意见反馈
            startActivity(FeedbackActivity.class);
        } else if (id == R.id.llPrivacy) {//隐私政策
            Intent intent = new Intent(getActivity(), WebActivity.class);
            intent.putExtra("url", "https://www.baidu.com");
            intent.putExtra("title", getString(R.string.privacy_policy));
            startActivity(intent);
        } else if (id == R.id.llAgreement) {//用户协议
            Intent intent = new Intent(getActivity(), WebActivity.class);
            intent.putExtra("url", "https://www.baidu.com");
            intent.putExtra("title", getString(R.string.user_agreement));
            startActivity(intent);
        }
    }

    @Override
    protected void initData() {
        mDataBinding.tvVersion.setText("v" + AppUtils.getAppVersionName());
    }
}